/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.bean;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.swing.JPanel;

/**
 * 说明：
 * Entity Name 商品
 * @Author：李智深
 * @Date：2012-03-14
 */
@Entity
@Table(name="ruipeng_tb_TCommodity")
public class TCommodity implements Serializable{

	private static final long serialVersionUID = 1L;

	private String CommodityID;//商品编号CHAR(15)PK
	
	private double Price;//价格DECIMAL(20,3)
	
	private String Des;//商品描述VARCHAR(512)
	
	private String Name;//商品名称VARCHAR(256)
	
	private int Point;//附送积分INTEGER
	
	private byte DiscountType;//打折类型TINYINT1为不打折 2为折扣 3为降价，即修正价格
	
	private double DisCount;//折扣率DECIMAL(20,3)
	
	private double DiscountPrice;//现价
	
	private double Score;//好评度
	
	private String Detail;//商品详细信息TEXT
	
	private String SmallPic;//小图片VARCHAR(256)
	
	private int ImageSetID;//形象编号CHAR(15)
	
	private byte Type;//类型TINYINT 1为正常商品 2为套餐
	
	private byte Status;//状态TINYINT 1为已发布 2为未发布
	
	private int ClickCount;//点击率INTEGER
	
	private Date CreateTime=new Date();//创建时间DATETIME
	
	private Date UpdateTime=new Date();//最后修改时间
	
	private String MainImage;//商品主形象VARCHAR(256)
	
	private byte MainImageType;//商品主形象类型 TINYINT1为一张大图片 2为3D形象 3为几张图片组成的图片集

	private int SaleCount;//销量INTEGER
	
	private int CommentCount;//总评论数
	
	private int ScoreCount;//总评分次数
	
	private String Barcode;//条形码CHAR(20)
	
	private double BatchPrice;//批发价DECIMAL(20,3)
	
	private String Unit;//商品计量单位VARCHAR(30)默认为所在目录的计量单位，也可以自定义设置，如果所在目录没有计量单位，则往上找一直找到一个计量单位

	private String MadePlace;//产地VARCHAR(32)
	
	private String Color;//颜色VARCHAR(10)
	
	private String Batch;//批次VARCHAR(16)
	
	private int Validity;//有效INTEGER1为天 2为月 3为年
	
	private byte ValidityUnit;//有效期单位INTEGER1为天 2为月 3为年

	private int MemCode;//助记码
	
	private boolean IsPubToSite; //
	
	private String SCatalogID;
	
	private String CabinetID;
	private double AvgPrice;//加权价格DECIMAL(20,3)加权价=（库存数量*加权价+采购价*采购数量）/（库存数量+采购数量）
	
	private String Std;//产品规格VARCHAR(64)
	
	private TProductCatalog TProductCatalog;//商品目录
	
	private Set<TStockAlarm> TStockAlarms=new HashSet<TStockAlarm>(0);//库存报警
	
	private Set<TStock> TStocks=new HashSet<TStock>(0);//商品库存
	
	private Set<TStockInOutDetail> TStockInOutDetails=new HashSet<TStockInOutDetail>(0);//入/出库单明细
	
	private Set<TCommoditySuitDetail> TCommoditySuitDetails=new HashSet<TCommoditySuitDetail>(0);//商品套餐
	
	private Set<TCommodityPicture> TCommodityPicture=new HashSet<TCommodityPicture>(0);//商品相片
	
	private String Cooking;//菜品调料
	
	private String IntoSales;//进销属性-0，标示不设定，1-仅进货，2-仅销售，3-进货销售
	
	private int num;//数量  不进入数据库，用于逻辑操作
	
	private Integer stockNum;//库存数量  不进数据库
	
	private String SuitDetailsID;
	private JPanel panel;//不仅数据库

	public TCommodity(){}
	
	public TCommodity(String commodityID, double price, String name,
			double discountPrice, double batchPrice, String barcode) {
		super();
		CommodityID = commodityID;
		Price = price;
		Name = name;
		DiscountPrice = discountPrice;
		BatchPrice = batchPrice;
		Barcode = barcode;
	}

	public TCommodity(String CommodityID){this.CommodityID=CommodityID;}
	
	public TCommodity(String commodityID, double price, String name,
		double discountPrice, String barcode, double batchPrice, String unit, double avgPrice) {
		super();
		CommodityID = commodityID;
		Price = price;
		Name = name;
		DiscountPrice = discountPrice;
		Barcode = barcode;
		BatchPrice = batchPrice;
		Unit = unit;
		AvgPrice = avgPrice;
	}
	
	public TCommodity(String commodityID, double price, String name, double discountPrice, 
			String barcode, double batchPrice, String unit, double avgPrice, double disCount) {
			super();
			CommodityID = commodityID;
			Price = price;
			Name = name;
			DiscountPrice = discountPrice;
			Barcode = barcode;
			BatchPrice = batchPrice;
			Unit = unit;
			AvgPrice = avgPrice;
			DisCount = disCount;
		}

	public TCommodity(String commodityID,  String name, double discountPrice, double DisCount, String Unit) {
		this.CommodityID = commodityID;
		this.Name = name;
		this.DiscountPrice = discountPrice;
		this.DisCount = DisCount;
		this.Unit = Unit;
	}
	
	public TCommodity(String commodityID, double price, String des, String name,
			int point, double disCount, double discountPrice, double score,
			String detail, byte type, byte status, int clickCount, Date createTime,
			Date updateTime, int saleCount, int commentCount, int scoreCount,
			String barcode, double batchPrice, String unit, int memCode,
			String std, String madePlace, String color, String batch,
			int validity, byte validityUnit, double avgPrice) {
		super();
		CommodityID = commodityID;
		Price = price;
		Des = des;
		Name = name;
		Point = point;
		DisCount = disCount;
		DiscountPrice = discountPrice;
		Score = score;
		Detail = detail;
		Type = type;
		Status = status;
		ClickCount = clickCount;
		CreateTime = createTime;
		UpdateTime = updateTime;
		SaleCount = saleCount;
		CommentCount = commentCount;
		ScoreCount = scoreCount;
		Barcode = barcode;
		BatchPrice = batchPrice;
		Unit = unit;
		MemCode = memCode;
		Std = std;
		MadePlace = madePlace;
		Color = color;
		Batch = batch;
		Validity = validity;
		ValidityUnit = validityUnit;
		AvgPrice = avgPrice;
	}
	
	@Id
	@Column(name = "CommodityID",length=15)
	public String getCommodityID() {
		return CommodityID;
	}

	public void setCommodityID(String commodityID) {
		CommodityID = commodityID;
	}

	@Column(name = "Price", precision = 20, scale = 3)
	public double getPrice() {
		return Price;
	}

	public void setPrice(double price) {
		Price = price;
	}

	@Column(name = "Des",length=512)
	public String getDes() {
		return Des;
	}

	public void setDes(String des) {
		Des = des;
	}

	@Column(name = "Name",length=256)
	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}

	@Column(name = "Point")
	public int getPoint() {
		return Point;
	}

	public void setPoint(int point) {
		Point = point;
	}

	@Column(name = "DiscountType")
	public byte getDiscountType() {
		return DiscountType;
	}

	public void setDiscountType(byte discountType) {
		DiscountType = discountType;
	}

	@Column(name = "DisCount", precision = 20, scale = 3)
	public double getDisCount() {
		return DisCount;
	}

	public void setDisCount(double disCount) {
		DisCount = disCount;
	}

	@Column(name = "DiscountPrice", precision = 20, scale = 3)
	public double getDiscountPrice() {
		return DiscountPrice;
	}

	public void setDiscountPrice(double discountPrice) {
		DiscountPrice = discountPrice;
	}

	@Column(name = "Score", precision = 20, scale = 3)
	public double getScore() {
		return Score;
	}

	public void setScore(double score) {
		Score = score;
	}

	@Column(name = "Detail",length=65535)
	public String getDetail() {
		return Detail;
	}

	public void setDetail(String detail) {
		Detail = detail;
	}

	@Column(name = "SmallPic",length=256)
	public String getSmallPic() {
		return SmallPic;
	}

	public void setSmallPic(String smallPic) {
		SmallPic = smallPic;
	}

	@Column(name = "ImageSetID")
	public int getImageSetID() {
		return ImageSetID;
	}

	public void setImageSetID(int imageSetID) {
		ImageSetID = imageSetID;
	}

	@Column(name = "Type")
	public byte getType() {
		return Type;
	}

	public void setType(byte type) {
		Type = type;
	}

	@Column(name = "Status")
	public byte getStatus() {
		return Status;
	}

	public void setStatus(byte status) {
		Status = status;
	}

	@Column(name = "ClickCount")
	public int getClickCount() {
		return ClickCount;
	}

	public void setClickCount(int clickCount) {
		ClickCount = clickCount;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CreateTime", nullable = false, length = 19)
	public Date getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(Date createTime) {
		CreateTime = createTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "UpdateTime", nullable = false, length = 19)
	public Date getUpdateTime() {
		return UpdateTime;
	}

	public void setUpdateTime(Date updateTime) {
		UpdateTime = updateTime;
	}

	@Column(name = "MainImage",length=256)
	public String getMainImage() {
		return MainImage;
	}

	public void setMainImage(String mainImage) {
		MainImage = mainImage;
	}

	@Column(name = "MainImageType")
	public byte getMainImageType() {
		return MainImageType;
	}

	public void setMainImageType(byte mainImageType) {
		MainImageType = mainImageType;
	}

	@Column(name = "SaleCount")
	public int getSaleCount() {
		return SaleCount;
	}

	public void setSaleCount(int saleCount) {
		SaleCount = saleCount;
	}

	@Column(name = "CommentCount")
	public int getCommentCount() {
		return CommentCount;
	}

	public void setCommentCount(int commentCount) {
		CommentCount = commentCount;
	}

	@Column(name = "ScoreCount")
	public int getScoreCount() {
		return ScoreCount;
	}

	public void setScoreCount(int scoreCount) {
		ScoreCount = scoreCount;
	}

	@Column(name = "Barcode",length=20)
	public String getBarcode() {
		return Barcode;
	}

	public void setBarcode(String barcode) {
		Barcode = barcode;
	}

	@Column(name = "BatchPrice", precision = 20, scale = 3)
	public double getBatchPrice() {
		return BatchPrice;
	}

	public void setBatchPrice(double batchPrice) {
		BatchPrice = batchPrice;
	}

	@Column(name = "Unit",length=30)
	public String getUnit() {
		return Unit;
	}

	public void setUnit(String unit) {
		Unit = unit;
	}

	@Column(name = "MadePlace",length=32)
	public String getMadePlace() {
		return MadePlace;
	}

	public void setMadePlace(String madePlace) {
		MadePlace = madePlace;
	}

	@Column(name = "Color",length=10)
	public String getColor() {
		return Color;
	}

	public void setColor(String color) {
		Color = color;
	}

	@Column(name = "Batch",length=16)
	public String getBatch() {
		return Batch;
	}

	public void setBatch(String batch) {
		Batch = batch;
	}

	@Column(name = "Validity")
	public int getValidity() {
		return Validity;
	}

	public void setValidity(int validity) {
		Validity = validity;
	}

	@Column(name = "ValidityUnit",length=5)
	public byte getValidityUnit() {
		return ValidityUnit;
	}
	public void setValidityUnit(byte validityUnit) {
		ValidityUnit = validityUnit;
	}
	
	@Column(name = "MemCode")
	public int getMemCode() {
		return MemCode;
	}

	public void setMemCode(int memCode) {
		MemCode = memCode;
	}

	@Column(name = "Std",length=64)
	public String getStd() {
		return Std;
	}

	public void setStd(String std) {
		Std = std;
	}
	
	@Column(name = "Cooking",length=10)
	public String getCooking() {
		return Cooking;
	}

	public void setCooking(String cooking) {
		Cooking = cooking;
	}

	@Column(name = "IntoSales", length = 6)
	public String getIntoSales() {
		return IntoSales;
	}

	public void setIntoSales(String intoSales) {
		IntoSales = intoSales;
	}

	@Column(name = "AvgPrice", precision = 20, scale = 3)
	public double getAvgPrice() {
		return AvgPrice;
	}

	public void setAvgPrice(double avgPrice) {
		AvgPrice = avgPrice;
	}
	
	@ManyToOne
	@JoinColumn(name="TProductCatalogID")
	public TProductCatalog getTProductCatalog() {
		return TProductCatalog;
	}

	public void setTProductCatalog(TProductCatalog tProductCatalog) {
		TProductCatalog = tProductCatalog;
	}

	@OneToMany(mappedBy="TCommodity",fetch=FetchType.EAGER)
	@JoinColumn(name="CommodityID")
	public Set<TStockAlarm> getTStockAlarms() {
		return TStockAlarms;
	}

	public void setTStockAlarms(Set<TStockAlarm> tStockAlarms) {
		TStockAlarms = tStockAlarms;
	}
	@OneToMany(mappedBy="TCommodity",fetch=FetchType.EAGER)
	@JoinColumn(name="CommodityID")
	public Set<TStock> getTStocks() {
		return TStocks;
	}

	public void setTStocks(Set<TStock> tStocks) {
		TStocks = tStocks;
	}
	@OneToMany(mappedBy="TCommodity")
	@JoinColumn(name="CommodityID")
	public Set<TStockInOutDetail> getTStockInOutDetails() {
		return TStockInOutDetails;
	}

	public void setTStockInOutDetails(Set<TStockInOutDetail> tStockInOutDetails) {
		TStockInOutDetails = tStockInOutDetails;
	}
	
	@OneToMany(mappedBy="TCommodity")
	@JoinColumn(name="CommodityID")
	public Set<TCommoditySuitDetail> getTCommoditySuitDetails() {
		return TCommoditySuitDetails;
	}

	public void setTCommoditySuitDetails(Set<TCommoditySuitDetail> tCommoditySuitDetails) {
		TCommoditySuitDetails = tCommoditySuitDetails;
	}
	
	@OneToMany(mappedBy="TCommodity")
	@JoinColumn(name="CommodityID")
	public Set<TCommodityPicture> getTCommodityPicture() {
		return TCommodityPicture;
	}

	public void setTCommodityPicture(Set<TCommodityPicture> tCommodityPicture) {
		TCommodityPicture = tCommodityPicture;
	}
	
	
	@Transient
	public int getNum() {
		return num;
	}


	public void setNum(int num) {
		this.num = num;
	}

	@Column(name = "IsPubToSite")
	public boolean isPubToSite() {
		return IsPubToSite;
	}
	public void setPubToSite(boolean isPubToSite) {
		IsPubToSite = isPubToSite;
	}
	@Transient
	public JPanel getPanel() {
		return panel;
	}

	public void setPanel(JPanel panel) {
		this.panel = panel;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return Name.toString();
	}
	public String getSCatalogID() {
		return SCatalogID;
	}
	public void setSCatalogID(String catalogID) {
		SCatalogID = catalogID;
	}
	public String getCabinetID() {
		return CabinetID;
	}
	public void setCabinetID(String cabinetID) {
		CabinetID = cabinetID;
	}

	@Transient
	public String getSuitDetailsID() {
		return SuitDetailsID;
	}

	public void setSuitDetailsID(String suitDetailsID) {
		SuitDetailsID = suitDetailsID;
	}

	@Transient
	public Integer getStockNum() {
		return stockNum;
	}

	public void setStockNum(Integer stockNum) {
		this.stockNum = stockNum;
	}
	
	
}
